package com.neusoft.neu24.his.hisapp.controller;

import com.neusoft.neu24.his.hisapp.HelloApplication;
import com.neusoft.neu24.his.hisapp.entity.Patient;
import com.neusoft.neu24.his.hisapp.util.GlobalData;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Modality;
import javafx.stage.Stage;

import java.io.IOException;

public class ResultViewController {
    @FXML
    TableColumn<Patient,String>  nameCloumn ;
    @FXML
    TableColumn<Patient,String>  ageCloumn ;
    @FXML
    TableColumn<Patient,String>  sexCloumn ;
    @FXML
    TableColumn<Patient,String>  statusCloumn ;

    @FXML
    TableView<Patient> tv_patients;

    public TableView<Patient> getTv_patients() {
        return tv_patients;
    }

    @FXML
    public void initialize(){
        nameCloumn.setCellValueFactory( new PropertyValueFactory("name"));
        ageCloumn.setCellValueFactory( new PropertyValueFactory("age"));
        sexCloumn.setCellValueFactory( new PropertyValueFactory("sex"));
        statusCloumn.setCellValueFactory( new PropertyValueFactory("status"));
        tv_patients.getItems().add( new Patient("张三","18","男","正常") );


    }
    @FXML
    public  void  tvMouseCliked() throws IOException {
        Stage  stage =new Stage();

        stage.initModality( Modality.APPLICATION_MODAL );
        stage.initOwner(GlobalData.primaryStage);

        FXMLLoader fxmlLoader = new FXMLLoader(  HelloApplication.class.getResource("list-view.fxml"));
        AnchorPane anchorPane =fxmlLoader.load();
        ListViewController  controller =  fxmlLoader.getController();
        controller.setMyStage(stage);
        controller.setResultViewController(this);
        Scene scene =new Scene(  anchorPane, 600, 400 );

        scene.setUserData( this );
        stage.setScene(scene);
        stage.setTitle("病人选择");
        stage.showAndWait();

    }
}
